<div class="wrapper activity-box">
	<div class="activity-box-container">
		<img id="box-img" src="__STYLE__/Box/images/box1.png">
	</div>
	<div class="activity-box-selector">
		<a id="btn-select" class="button button-rounded button-flat-primary button-small">换个盒子</a>
	</div>
</div>

<div class="wrapper activity-action">
	<a id="btn-host" class="button button-block button-rounded button-flat-royal">领取礼盒</a>
	<a id="btn-share" class="button button-block button-rounded button-flat-caution">分享给朋友们</a>
</div>

<script type="text/javascript">
	$(function() {
	    var boxId = 1;
		$("#btn-share").click(function() {
			simapp.tips("分享ta吧，一起赢礼品！");
		});
		$("#btn-select").click(function(){
		    boxId++;
		    (boxId > 6) && (boxId = 1);
		    var boxUrl = "__STYLE__/Box/images/box" + boxId + ".png";
		    $("#box-img").attr("src", boxUrl);
		});
		$("#btn-host").click(function(){
		    $.ajax({
		    	type:"POST",
		    	url:"__CONTROLLER__/host?debug",
		    	data:{
		    	    cid: activity.cid,
		    	    aid: activity.id,
		    	    uid: userInfo.id,
		    	    boxId: boxId
                },
                beforeSend: function(){
                    simapp.toast("正在领取盒子……");
                },
                success: function(res){
                    simapp.toast(res.msg);
                },
                error: function(){
                    simapp.toast("领取盒子人太多了，请再试一次吧！" + "__CONTROLLER__/host" + (debug ? "/debug/" + debug : ''));
                }
		    });
		})
	});
</script>